﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Power.Model;
using System.Data;
using System.Data.SqlClient;

namespace Power.DAL
{
    public class ListtempDAL
    {

        public ListTE[] ToFind(string device)
        {
            DataTable dt = SqlHelper.ExecuteDataTable("select * from T_Monitor where Device=@device", new SqlParameter("@device", device));
            //ListTE mon = new ListTE();

            //mon = ToListTE(dt.Rows[0]);
            
            ListTE[] mons = new ListTE[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                mons[i] = ToListTE(dt.Rows[i]);
            }


            

            return mons;
        }



        private ListTE ToListTE(DataRow row)
        {
            ListTE op = new ListTE();
            op.Id = (long)row["Id"];
            op.TempI = (string)row["TempI"];
            op.TempO = (string)row["TempO"];
            op.GPSL = (string)row["GPSL"];
            op.GPSW = (string)row["GPSW"];
            op.Dtime = row["DTime"].ToString();
            
            return op;
        }



    }
}
